package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gears_software.sxdc.dccx.ui.view.MyTripListItemView;
import com.gears_software.sxdc.dccx.ui.view.MyTripListItemView_;
import com.gears_software.sxdc.dccx.ui.view.SearchListItemView;
import com.gears_software.sxdc.dccx.ui.view.SearchListItemView_;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by SunMuran on 2017/8/10.
 */

public class SearchAdapter extends BaseAdapter {
    Context context;
    private List<HashMap<String,String>> addressData;

    public SearchAdapter(Context context, List<HashMap<String, String>> addressData) {
        this.context = context;
        this.addressData = addressData;
    }

    @Override
    public int getCount() {
        return addressData.size();
    }

    @Override
    public Object getItem(int position) {
        return addressData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SearchListItemView itemView;
        if(convertView==null){
            itemView = SearchListItemView_.build(context);
        } else {
            itemView = (SearchListItemView) convertView;
        }
        itemView.bind(addressData.get(position));

        return itemView;
    }
}
